package com.xpc.mapper;

import com.xpc.pojo.vo.AffairInfo;
import com.xpc.pojo.vo.AffairUrlInfo;
import com.xpc.pojo.vo.UrlList;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * Project：UniversityGradeAdministrationSystem
 * Date：2022/6/14
 * Time：14:09
 * Description：TODO
 *
 * @author 南北辰的键盘
 * @version 1.0
 */
@Mapper
public interface AffairInfoMapper {

    /**
     * 获取全部事务列表信息
     * @return
     */
    @Select("select a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num num2 ,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u where a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id;")
    List<AffairInfo> selectAllAffairInfo();

//    @Select("select distinct a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num ,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u where  aco.theme like #{s} and a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id;")
//    List<AffairInfo> selectLike(@Param("s") String s);

    /**
     * 通过事务ID查找在线文档链接
     * @param id
     * @return
     */
    @Select("select a.url url from  ctas.affair a where a.id =#{id};")
    List<UrlList> selectLinkById(@Param("id")String id);

    /**
     * 通过id查找上传文档链接
     * @param id
     * @return
     */
    @Select("select a.f_url url from  ctas.affair a where a.id =#{id};")
    List<UrlList> selectFileById (@Param("id")String id);

    /**
     * 通过id查找信息
     * @param id
     * @return
     */
    @Select("select a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num num2,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u where a.id= #{id} and a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id;")
    AffairUrlInfo selectAffairInfoById(@Param("id")String id);


    /**
     * 所有完成
     * @return
     */
    @Select("select a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num num2,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u where a.start = 0 and a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id ORDER BY a.create_time DESC;")
    List<AffairInfo> selectAllFulfillAffairInfo();
//    @Insert("")

    /**
     * 所有未完成
     * @return
     */
    @Select("select a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num num2,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u where a.start = 1 and a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id ORDER BY a.create_time ASC;")
    List<AffairInfo> selectAllNoFulfillAffairInfo();


    @Select("select distinct a.id id, acl.name type,a.start_time startDate,a.end_time endDate, u.name creater,aco.theme title,aco.particular content,a.priority priority,a.num ,a.notice_num ,a.start state,a.father,a.son from ctas.affair a,ctas.affair_classification acl,ctas.affair_content aco,ctas.user u ,ctas.process p where p.user_id= #{id} and a.a_cl_id = 10 and p.affair_id = a.id and a.creator = u.user_id and a.a_cl_id = acl.id and a.a_co_id = aco.id;")
    List<AffairInfo> selectInform(@Param("id")String id);


//    @Select("")
}
